﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GetCar
{
    class Client
    {
        private String FirstName;
        private String LastName;
        private String Age;
        private List<Car> MyCarList = new List<Car>();
        private CarFactory TheCarFactory;

        public Client(CarFactory Factory, String FName, String LName, String TheAge)
        {
            FirstName = FName;
            LastName = LName;
            Age = TheAge;
            this.TheCarFactory = Factory;
        }

        public String GetFName()
        {
            return FirstName;
        }

        public String GetLName()
        {
            return LastName;
        }

        public String GetAge()
        {
            return Age;
        }

        public void CommandCar(String CarType, string Colour, string Transmission, string Motor)
        {
            Car MyNewCar = TheCarFactory.CommandCar(CarType, Colour, Transmission, Motor);
            MyCarList.Add(MyNewCar);
        }

        public void ReturnCar(int CarNumber)
        {
            if (MyCarList.Count < CarNumber)
            {
                Console.WriteLine("There is no car with that number in the list");
                return;
            }

            Car ReturnCarObject = MyCarList[CarNumber];
            MyCarList.RemoveAt(CarNumber);
            TheCarFactory.PutCarBack(ReturnCarObject);
        }

        public void PrintCarList()
        {
            if (MyCarList.Count == 0)
            {
                Console.WriteLine("The client has no cars");
                return;
            }

            foreach (Car car in MyCarList)
                Console.WriteLine(car.GetCarType() + " " + car.GetColour() + " " + car.GetFacility() + " " + car.GetMoto() + " " + car.GetTransmission());
        }


    }
}
